<?php


class Ranking extends CI_Controller {

	function __construct()
	{
		parent::__construct();

		
	}	
	
	function index()
	{
		$per_page = 10;
		
		$this->load->helper('url');
		$this->load->library('pagination');
		$this->load->model('forms/colegio','dao');
		$model['listado'] = $this->dao->getRankingColegios(
			$this->input->get_post('colegio',true),
			$this->uri->segment(4),
			$per_page
		);
		
		$config['base_url'] = site_url('forms/ranking/index');
		$config['total_rows'] = $this->dao->getCountColegios();
		$config['per_page'] = $per_page;
		$config['uri_segment'] = 4;
		$config['num_links'] = 10;
		
		$this->pagination->initialize($config); 
		$model['paginator'] = $this->pagination->create_links();
		
		$this->load->view('forms/ranking_v',$model);
		
	}

	
	function autocomplete()
    {    
    	log_message("debug",":::autocomplete:".$this->input->post('queryString'));
        $this->load->model('forms/codigos_colegio','dao_codcolegios');
        $query= $this->dao_codcolegios->get_autosugnombre();
        
        foreach($query->result() as $row):
        
        echo "<li><a href=\"javascript:fill('".$row->codigo."#".$row->nombre."');\"> ".$row->nombre."</a></li>";

        endforeach;    
    } 	
	
	function detail(){
		
		$this->load->helper('url');
		$this->load->library('codigos');	
		$this->load->model('forms/colegio','dao');
		$this->load->model('mediadao','dao_media');

		$params = array('api_key' => '02812421d8ca4f612e546c9c948bb856', 'secret' => 'a816040ee5a814af');
		$this->load->library('phpflickr',$params);
		
		$model['colegio'] = $this->dao->getColegio($this->uri->segment(4));
		$model['actividades']=$this->dao->getDistinctActividadesRealizadasColegio($this->uri->segment(4));
		$model['recaudacion']=$this->dao->getTotalRecaudadoColegio($this->uri->segment(4));
		$model['medios']=$this->dao_media->getVideosByCodigoColegio($this->uri->segment(4));
		$this->load->view('forms/ranking_detalle_v',$model);
		
	}
	
	
}
/* End of file acc_foto_data.php */
/* Location: ./application/controllers/forms/ranking.php */